package com.cangxuan.backend.controller;

import com.alibaba.fastjson.JSONArray;
import com.cangxuan.backend.annotation.Check;
import com.cangxuan.backend.annotation.check.Max;
import com.cangxuan.backend.annotation.check.NotNull;
import com.cangxuan.backend.bean.Page;
import com.cangxuan.backend.entity.Goods;
import com.cangxuan.backend.service.IGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 首页控制器
 * author:何程城
 */
@RestController
@RequestMapping("home")
@Api(tags = "首页相关接口")
public class HomeController extends BaseController {
    IGoodsService goodsService;

    @Autowired
    public void setGoodsService(IGoodsService goodsService) {
        this.goodsService = goodsService;
    }
    @Data
    @ApiModel("首页藏品列表响应实体类")
    @AllArgsConstructor
    public static class CollectionsResponse {
        private int id;
        private String image;
        private String name;
        private String issuer;
        private int circulation;
        private int price;
    }
    /**
     * 获取首页数字藏品
     * @param pageIndex
     * @param pageSize
     * @return
     */
    @GetMapping("collections/{pageIndex}/{pageSize}")
    @ApiOperation("首页数字藏品列表")
    public Object page(@PathVariable int pageIndex, @PathVariable int pageSize) {
        List<Goods> goodsList = goodsService.page(pageIndex, pageSize);
        return success(goodsList);
    }

    @GetMapping("calendar/{pageIndex}/{pageSize}")
    @ApiOperation("首页数字藏品发售日历")
    public Object list(@PathVariable int pageIndex, @PathVariable int pageSize) {
        List<Goods> goodsList = goodsService.calendar(pageIndex, pageSize);
        return success(goodsList);
    }
}
